package org.ricks.net.codec;

import org.ricks.common.json.JSONUtil;

/**
 * @author chenwei
 * @Description:
 * @date 2023/1/410:41
 */
public class StringDataCodec implements DataCodec{

    @Override
    public byte[] encode(Object data) {
        return JSONUtil.toJsonStr(data).getBytes();
    }

    @Override
    public <T> T decode(byte[] data, Class<?> dataClass) {
        return (T) JSONUtil.toBean(new String(data),dataClass);
    }
}
